use charming::{
    Chart,
    component::{
        ParallelAxis, ParallelAxisDefault, ParallelCoordinate, Title, VisualMap, VisualMapChannel,
        VisualMapType,
    },
    element::{AxisType, NameLocation, ParallelLayout, TextStyle, Tooltip},
};

pub fn chart() -> Chart {
    Chart::new()
        .title(
            Title::new()
                .text("Groups")
                .top(0)
                .left(0)
                .text_style(TextStyle::new().color("#fff")),
        )
        .tooltip(
            Tooltip::new()
                .padding(10)
                .background_color("#222")
                .border_color("#777")
                .border_width(1),
        )
        .background_color("#333")
        .visual_map(
            VisualMap::new()
                .show(true)
                .type_(VisualMapType::Piecewise)
                .categories(vec![
                    "Demon Hunter",
                    "Blademaster",
                    "Death Knight",
                    "Warden",
                    "Paladin",
                ])
                .dimension(1)
                .in_range(VisualMapChannel::new().color(vec!["#d94e5d", "#eac736", "#50a3ba"]))
                .out_range(VisualMapChannel::new().color(vec!["ccc"]))
                .top(20)
                .text_style(TextStyle::new().color("#fff"))
                .realtime(false),
        )
        .parallel_axis(
            ParallelAxis::new()
                .dim(16)
                .name("id")
                .name_location(NameLocation::End),
        )
        .parallel_axis(
            ParallelAxis::new()
                .dim(2)
                .name("protein")
                .name_location(NameLocation::End),
        )
        .parallel_axis(
            ParallelAxis::new()
                .dim(4)
                .name("sodium")
                .name_location(NameLocation::End),
        )
        .parallel_axis(
            ParallelAxis::new()
                .dim(3)
                .name("calcium")
                .name_location(NameLocation::End),
        )
        .parallel_axis(
            ParallelAxis::new()
                .dim(5)
                .name("fiber")
                .name_location(NameLocation::End),
        )
        .parallel_axis(
            ParallelAxis::new()
                .dim(6)
                .name("vitaminc")
                .name_location(NameLocation::End),
        )
        .parallel_axis(
            ParallelAxis::new()
                .dim(7)
                .name("potassium")
                .name_location(NameLocation::End),
        )
        .parallel_axis(
            ParallelAxis::new()
                .dim(8)
                .name("carbohydrate")
                .name_location(NameLocation::End),
        )
        .parallel_axis(
            ParallelAxis::new()
                .dim(9)
                .name("sugars")
                .name_location(NameLocation::End),
        )
        .parallel_axis(
            ParallelAxis::new()
                .dim(10)
                .name("fat")
                .name_location(NameLocation::End),
        )
        .parallel_axis(
            ParallelAxis::new()
                .dim(11)
                .name("water")
                .name_location(NameLocation::End),
        )
        .parallel_axis(
            ParallelAxis::new()
                .dim(12)
                .name("calories")
                .name_location(NameLocation::End),
        )
        .parallel_axis(
            ParallelAxis::new()
                .dim(13)
                .name("saturated")
                .name_location(NameLocation::End),
        )
        .parallel_axis(
            ParallelAxis::new()
                .dim(14)
                .name("monounsat")
                .name_location(NameLocation::End),
        )
        .parallel_axis(
            ParallelAxis::new()
                .dim(15)
                .name("polyunsat")
                .name_location(NameLocation::End),
        )
        .parallel(
            ParallelCoordinate::new()
                .left(280)
                .top(20)
                .width(400)
                .layout(ParallelLayout::Vertical)
                .parallel_axis_default(
                    ParallelAxisDefault::new()
                        .type_(AxisType::Value)
                        .name("nutrients")
                        .name_location(NameLocation::End)
                        .name_gap(20)
                        .name_text_style(TextStyle::new().color("#fff").font_size(14)),
                ),
        )
}
